php chunk array

56

array_chunk in php -

Input : $input_array = array('a', 'b', 'c', 'd', 'e');
        array_chunk($input_array, 2);
Output : Array(
                [0] => Array
                (
                    [0] => a
                    [1] => b
                )
                [1] => Array
                (
                    [0] => c
                    [1] => d
                )
                [2] => Array
                (
                    [0] => e
                )
            )

Input : $input_array = array('a', 'b', 'c', 'd', 'e');
       array_chunk($input_array, 2, true)
Output :    Array
            (
                [0] => Array
                (
                    [0] => a
                    [1] => b
                )
                [1] => Array
                (
                    [2] => c
                    [3] => d
                )
                [2] => Array
                (
                    [4] => e
                )
            )

Comments

Submit
0 Comments